import { IsString, IsOptional, IsObject, IsEnum } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

// 创建基础 DTO 类，包含共同的字段
class BaseWorkflowDto {
  @ApiProperty()
  @IsString()
  name: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  description?: string;

  @ApiProperty()
  @IsString()
  author: string;

  @ApiProperty()
  @IsString()
  model_type: string;

  @ApiProperty()
  @IsEnum(['text2img', 'img2img', 'portrait'])
  category: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  preview_image?: string;

  @ApiProperty()
  @IsOptional()
  @IsObject()
  param_schema?: Record<string, any>;

  @ApiProperty()
  @IsOptional()
  @IsObject()
  workflow_json?: Record<string, any>;
}

// 创建工作流 DTO，继承基础 DTO
export class CreateWorkflowDto extends BaseWorkflowDto {}

// 更新工作流 DTO，所有字段都是可选的
export class UpdateWorkflowDto implements Partial<BaseWorkflowDto> {
  @ApiProperty()
  @IsOptional()
  @IsString()
  name?: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  description?: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  author?: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  model_type?: string;

  @ApiProperty()
  @IsOptional()
  @IsEnum(['text2img', 'img2img', 'portrait'])
  category?: string;

  @ApiProperty()
  @IsOptional()
  @IsString()
  preview_image?: string;

  @ApiProperty()
  @IsOptional()
  @IsObject()
  param_schema?: Record<string, any>;

  @ApiProperty()
  @IsOptional()
  @IsObject()
  workflow_json?: Record<string, any>;
} 